<template>
  <div class="interested-box" v-if="list.length">
    <div class="title">您可能感兴趣</div>
    <div class="list-box">
      <el-row :gutter="22">
        <el-col :span="8" v-for="(item, index) of list" :key="index">
          <div class="item-box" @click="onDetail(item)">
            <div class="item-img" :style="{backgroundImage: 'url(' + item.coverUrl + ')'}"></div>
            <div class="item-title">
              <div class="name">{{item.name}}</div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { articlesRecommend } from '@/api/api';

export default {
  props: ['uuid'],
  data() {
    return {
      list: []
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    async getList() {
      const uuid = this.uuid || this.$route.query.uuid
      const res = await articlesRecommend(uuid);
      if (res.list) {
        this.list = res.list;
      }
    },
    onDetail(item) {
      let routerJump = this.$router.resolve({ name: 'InformationDetail', query: {uuid: item.uuid} });
      window.open(routerJump.href, '_blank');
    }
  }
}
</script>

<style lang="scss" scoped>
.interested-box {
  margin-bottom: 52px;
  .title {
    height: 32px;
    font-size: 24px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #272727;
    line-height: 32px;
    margin-bottom: 24px;
  }
  .list-box {
    .item-box {
      margin-bottom: 20px;
      cursor: pointer;
      .item-img {
        width: 100%;
        height: 152px;
        background-size: cover;
        border-radius: 4px 4px 0px 0px;
      }
      .item-title {
        width: 100%;
        height: 68px;
        padding: 12px 16px;
        box-sizing: border-box;
        background: #F9F9F9;
        border-radius: 0px 0px 4px 4px;
        font-size: 14px;
        
        font-weight: 400;
        color: #272727;
        line-height: 20px;
        .name {
          line-height: 20px;
          max-height: 40px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          overflow: hidden;
          word-break: break-all;
        }
      }
    }
  }
}
</style>